<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,mybean.ExamBean,mybean.DBBean" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>login</title>
</head>
<body>
<jsp:useBean id="Exam" class="mybean.ExamBean" />
<jsp:setProperty name="Exam" property="studentid" />
<jsp:setProperty name="Exam" property="pass" />
<%
  String Studentid=Exam.getstudentid();
  String QueryUser="select Name,Pass from Users where Student_ID=";
  String QueryUsers_answer_Tables="select * from Users_answer_Tables where Student_ID=";
  String SQL_QueryUsers=QueryUser+"'"+Studentid+"'";
  String SQL_QueryUsers_answer_Tables=QueryUsers_answer_Tables+"'"+Studentid+"'";
  %> 

<%
	DBBean conn=new DBBean();
	try
	{
		ResultSet rsLogin=conn.doQuery(SQL_QueryUsers);
		ResultSet rsCheck=conn.doQuery(SQL_QueryUsers_answer_Tables);
if(rsLogin.next()) 
{
    
	if((Exam.getpass()).equals(rsLogin.getString("Pass")))
	   {
	    
		String Name=rsLogin.getString("Name");
	    session.setAttribute("Studentid",Studentid);
		if(rsCheck.next())
	    response.sendRedirect("Query.jsp");
		  else
	    {
		  int M=(new java.util.Date()).getMinutes();
          int H=(new java.util.Date()).getHours();
		  String SH=Integer.toString(H);
		  String SM=Integer.toString(M);
		  session.setAttribute("Name",Name);
		  session.setAttribute("SM",SM);
		  session.setAttribute("SH",SH);
		  response.sendRedirect("jspExam.jsp");
	      }
	    }
	else
	    response.sendRedirect("error.jsp");
}
else
    response.sendRedirect("error.jsp");
 
        conn.closeConnection();

 
      }

	catch(Exception e)
	{
	}
%>
 </body>
</html>
